from django_filters import rest_framework as filters
from app1.models import UserInfo,Addr


class UserInfoFilter(filters.FilterSet):
    # 自定义过滤器类
    # min_price = filters.NumberFilter(field_name='price', lookup_expr='gte')
    # max_price = filters.NumberFilter(field_name='price', lookup_expr='lte')
    #
    class Meta:
        model = UserInfo
        fields = ['name', 'id']


class AddrInfoFilter(filters.FilterSet):
    # 自定义过滤器类
    # min_price = filters.NumberFilter(field_name='price', lookup_expr='gte')
    # max_price = filters.NumberFilter(field_name='price', lookup_expr='lte')
    #
    name = filters.CharFilter(lookup_expr='icontains')
    class Meta:
        model = Addr
        fields = ['user']